Repository navigation
Support enumDescriptions and markdownEnumDescriptions - #178
Suyog241005 wants to merge 5 commits into
Conversation
619f828 to
e3f63af
Compare
|
Hi @jdesrosiers, this is ready for review. It follows the same approach as the |
|
The CI failure is in |
e3f63af to
1a66a6d
Compare
jdesrosiers
left a comment
There was a problem hiding this comment.
I pushed a failing test. A schema that applies twice at a location should show its enum description once, the same as description. Right now completions show it twice.
Fixed. Value completions were taking the location's annotations from the evaluation and the value's from the value set, so the same schema was in both lists as different records. The value set now gives all of a member's annotations deduplicated by identity, and the provider uses that. I also added the same test for a partially typed value, which went through the evaluation path and had the same problem. |
VS Code's enumDescriptions describes each enum value by its position in enum, so an annotation needs the enum values of its schema to find the description of a value. enum isn't an annotation keyword, so its compiled values are copied into a schema's annotation record when the record is created, both during evaluation and when completions are built. They never create a record on their own, so schemas with only an enum contribute nothing and the order of annotations is unchanged.
…tions Each enum value completion is documented with the description at its position in the schema's enumDescriptions, preferring markdownEnumDescriptions when there is one. A value without a description at its position isn't documented and extra descriptions are ignored, as in VS Code. The description follows the deprecation message and the title and description of the value. The description comes from the schema of the value's location, or of an alternative that admits the value. Reading an unknown keyword validates it against the meta-schema, which would be repeated for every completion at a location, so the validated value is now kept per annotation record.
Hovering an enum value shows the description at its position in enumDescriptions, or markdownEnumDescriptions, after the titles and descriptions that apply to it. The value is matched by its canonical JSON, the form the enum values are compiled to, so an object value is matched no matter how its keys are ordered. Hovering a property key or the colon of a property doesn't describe the value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Value completions took the location's annotations from the evaluation and the completion's from its value set. A schema that applies both unconditionally and as an anyOf alternative was in both lists as different records, so its enum description was shown twice. A value set can now give all the annotations of a member, the location's and the member's own, deduplicated by identity like its other annotations. Value completions use those for enum descriptions. Taking the location's annotations from the value set also means a partially typed value is described the same as an absent one. An enum description in a parent's `if` schema was shown only for a partially typed value, because completions don't come from `if`; now it isn't shown for either.
965266f to
12d61ae
Compare
Closes #99
Supports VS Code's
enumDescriptionsandmarkdownEnumDescriptions, arrays of strings matched by position to the schema'senum.markdownEnumDescriptionsis preferred, a value without a description at its position isn't documented, and extra descriptions are ignored, as in VS Code. The description follows the deprecation message and the title and description of the value.enumis compiled to, so object values match no matter how their keys are ordered.Design
enumisn't an annotation keyword, so an annotation record didn't have the values a description is matched to.LspEvaluationPluginnow copies the compiled enum values into a schema's annotation record when an annotation keyword creates it. They never create a record on their own, so schemas with only an enum contribute nothing and the order of annotations is unchanged.The validated value of an unknown keyword and the positions of the enum values are kept per record, because the accessors are called for every completion at a location.
A schema that applies to a location both unconditionally and as an anyOf alternative (for example
$ref'd in both places) is described once: the value set gives all the annotations of a member, the location's and its own, deduplicated by identity like its other annotations.Screenshots
Hover on a value shows the description after the title and description:
Hover on the key doesn't:
Completions for a plain enum, an anyOf alternative, and numbers:
markdownEnumDescriptionspreferred overenumDescriptions: